package com.company;

import java.util.*;

public class Task3 {
    public static void main(String[] args) {
        //todo 3. 编写一段程序，统计这段文字
        // "This class implements the <tt>Set</tt> interface, backed by a hash table(actually a <tt>HashMap</tt> instance).  It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time.  This class permits the <tt>null</tt> element."
        // 中不重复字符的数量。
        String str = "This class implements the <tt>Set</tt> interface, backed by a hash table(actually a <tt>HashMap</tt> instance).  It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time.  This class permits the <tt>null</tt> element.";
        HashSet<Character> repeatSet = new HashSet<>();
        HashSet<Character> noRepeatSet = new HashSet<>();

        int len = str.length();
        for (int i = 0; i < len; ++i) {
            Character s = str.charAt(i);
            if (repeatSet.contains(s)) {
                noRepeatSet.remove(s);
            } else {
                repeatSet.add(s);
                noRepeatSet.add(s);
            }
        }

        System.out.println(repeatSet.toString());
        System.out.println(noRepeatSet.toString());
        System.out.println("不重复字符的数量: " + noRepeatSet.size());
    }

}
